import { Injectable } from '@nestjs/common';
import { AuthenticationStrategy } from './authentication-strategy.interface';
import { PhoneVerificationStrategy } from './phone-verification.strategy';
import { UsernamePasswordStrategy } from './username-password.strategy';

// authentication-selector.ts
@Injectable()
export class AuthenticationSelector {
  constructor(
    private readonly phoneVerificationStrategy: PhoneVerificationStrategy,
    private readonly usernamePasswordStrategy: UsernamePasswordStrategy,
  ) { }

  selectStrategy(strategyName: string): AuthenticationStrategy {
    if (strategyName === 'mobile') {
      return this.phoneVerificationStrategy;
    } else if (strategyName === 'password') {
      return this.usernamePasswordStrategy;
    } else {
      throw new Error('Invalid authentication strategy');
    }
  }
}
